<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>React Router</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="../../../libs/prop-types/15.6.0/prop-types.js"></script>
    <script src="../../../libs/react/16.2.0/umd/react.development.js"></script>
    <script src="../../../libs/react-dom/16.2.0/umd/react-dom.development.js"></script>
    <script src="../../../libs/react-router-dom/4.2.2/react-router-dom.js"></script>
    <script src="../../../libs/babel-standalone/6.26.0/babel.min.js"></script>
    <script src="../../../libs/classnames/2.2.5/index.js"></script>

</head>

<body>
    <div id="root"></div>
    <div id='t2'></div>
</body>
<script type="text/babel">

    class ActionLink extends React.Component {
        constructor(props) {
            super(props);
            this.handleClick.bind(this);
        }
        handleClick(e) {
            e.preventDefault();
            console.log('The link was clicked.');
        }

        render() {
            return (
                <a href="#" onClick={this.handleClick}>
                    Click me
                </a>
            );
        }
    }

    class Toggle extends React.Component {
        constructor(props) {
            super(props);
            this.state = { isToggleOn: true };

            // This binding is necessary to make `this` work in the callback
            this.handleClick = this.handleClick.bind(this);
        }

        handleClick() {
            this.setState(prevState => ({
                isToggleOn: !prevState.isToggleOn
            }));
        }

        render() {
            return (
                <button onClick={this.handleClick}>
                    {this.state.isToggleOn ? 'ON' : 'OFF'}
                </button>
            );
        }
    }


    ReactDOM.render(<ActionLink />, document.getElementById('root'));
    ReactDOM.render(<Toggle />, document.getElementById('t2'));


</script>

</html>